<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改页面</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/component/pear/css/pear.css" />
</head>
<body>
<%--	${pageContext.request.contextPath}/user/update--%>
<form class="layui-form" action="" method="post">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">id</label>
                <div class="layui-input-block">
                    <input type="text" name="deptId"  value="${requestScope.sysDept.deptId}" lay-verify="title" autocomplete="off"
                           placeholder="请输入Id" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">父级id</label>
                <div class="layui-input-block">
                    <input type="text" name="parentId"  value="${requestScope.sysDept.parentId}" lay-verify="title" autocomplete="off"
                           placeholder="请输入Id" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">部门名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="deptName"  value="${requestScope.sysDept.deptName}" lay-verify="title" autocomplete="off"
                           placeholder="请输入标题" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">负责人</label>
                <div class="layui-input-block">
                    <input type="text" name="leader"  value="${requestScope.sysDept.leader}" lay-verify="title" autocomplete="off"
                           placeholder="请输入标题" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">电话号码</label>
                <div class="layui-input-block">
                    <input type="text" name="phone" value="${requestScope.sysDept.phone}" lay-verify="title" autocomplete="off" placeholder="请输入标题"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态:</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="0" ${requestScope.sysDept.status.equals("0") ? "checked" : ""} title="正常" >
                    <input type="radio" name="status" value="1" ${requestScope.sysDept.status.equals("1") ? "checked" : ""} title="删除">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="email" name="email" value="${requestScope.sysDept.email}" lay-verify="title" autocomplete="off"
                           placeholder="请输入标题" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="dept-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="${pageContext.request.contextPath}/statics/component/layui/layui.js"></script>
<script src="${pageContext.request.contextPath}/statics/component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery'], function() {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(dept-save)', function(data) {
            $.ajax({
                url: '${pageContext.request.contextPath}/dept/updatedept',
                data: data.field,
                dataType: 'json',
                // contentType: 'application/json',
                type: 'post',
                success: function(result) {
                    if (result = 1) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("dept-table");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>
